package kaka.controls
{
	import com.greensock.TweenLite;
	import com.greensock.TweenMax;
	
	import flash.display.Bitmap;
	import flash.events.Event;
	import flash.events.FocusEvent;
	import flash.events.MouseEvent;
	
	import mx.core.IVisualElement;
	import mx.core.IVisualElementContainer;
	import mx.events.FlexEvent;
	import mx.graphics.ImageSnapshot;
	
	import spark.components.Image;
	import spark.components.TextInput;
	import spark.primitives.BitmapImage;

	/**
	 * 带发光暗黑背景的输入框
	 * @author kaka
	 * @date 2011.9.18
	 * 
	 * @param isFocusIn 输入框是否已获取焦点
	 **/
	public class VisualTextInput extends TextInput
	{
		//是否获得焦点
		private var isFocusIn:Boolean=false;
		public function VisualTextInput()
		{
			super();
			this.setStyle("focusThickness",0);
			addEventListener(MouseEvent.MOUSE_OVER,mouseHandler);
			addEventListener(MouseEvent.MOUSE_OUT,mouseHandler);
			addEventListener(FocusEvent.FOCUS_IN,focusHandler);
			addEventListener(FocusEvent.FOCUS_OUT,focusHandler);
		}
		protected function mouseHandler(event:MouseEvent):void
		{
			if(event.type==MouseEvent.MOUSE_OVER)
			    TweenMax.to(this, 1.5, {colorMatrixFilter:{colorize:0xf08519,amount:0.5}});
			
			else
				TweenMax.to(this, 1.5, {colorMatrixFilter:{colorize:0xf08519, amount:0.0}});
			
		}
		protected function focusHandler(event:FocusEvent):void
		{
			if(event.type==FocusEvent.FOCUS_IN)
				TweenMax.to(this, 1.5, {colorMatrixFilter:{colorize:0xf08519,amount:0.5}});
			else
				TweenMax.to(this, 1.5, {colorMatrixFilter:{colorize:0xf08519, amount:0.0}});
		}
//		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
//		{
//			super.updateDisplayList( unscaledWidth, unscaledHeight );
//			//this.textField.height = this.textField.textHeight;
//			//this.textField.y = this.height/2 -this.textField.height/2
//		}


	}
}